home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
VObject.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-17
|
7KB
|
253 lines
#ifndef VObject_First
#ifdef __GNUG__
//pragma once
#pragma interface
#endif
#define VObject_First
#include "Types.h"
#include "Port.h"
#include "EvtHandler.h"
#include "Command.h"
#include "CmdNo.h"
class Clipper;
class View;
class Window;
class Collection;
enum VObjFlags {
eVObjEnabled = BIT(eEvtLast+1),
eVObjOpen = BIT(eEvtLast+2),
eVObjHFixed = BIT(eEvtLast+3),
eVObjVFixed = BIT(eEvtLast+4),
eVObjLayoutCntl = BIT(eEvtLast+5),
eVObjKbdFocus = BIT(eEvtLast+6),
eVObjShowPage = BIT(eEvtLast+7),
eVObjHighlight = BIT(eEvtLast+8),
eVObjDefault = eVObjEnabled,
eVObjLast = eEvtLast + 8
};
enum VObjAlign {
eVObjHLeft = BIT(0),
eVObjHCenter = BIT(1),
eVObjHRight = BIT(2),
eVObjHExpand = BIT(3),
eVObjHEqual = BIT(4),
eVObjHGapExpand = BIT(5),
eVObjH = eVObjHLeft|eVObjHCenter|eVObjHRight,
eVObjVTop = BIT(8),
eVObjVBase = BIT(9),
eVObjVCenter = BIT(10),
eVObjVBottom = BIT(11),
eVObjVExpand = BIT(12),
eVObjVEqual = BIT(13),
eVObjVGapExpand = BIT(14),
eVObjV = eVObjVTop|eVObjVBase|eVObjVCenter|eVObjVBottom
};
extern const int cAutoSize;
extern Point gBorder;
//---- VObject -----------------------------------------------------------------
class VObject : public EvtHandler {
VObject *container;
public:
Rectangle contentRect;
public:
MetaDef(VObject);
VObject(Rectangle r, int id= cIdNone);
VObject(int id= cIdNone);
~VObject();
void FreeAll();
Point GetPortPoint(Point p);
virtual Rectangle GetViewedRect();
virtual int Size();
virtual Iterator *MakeIterator(bool forward= TRUE);
virtual VObject *SetAt(int at, VObject *vop);
virtual VObject *At(int n);
virtual void Add(VObject*);
virtual VObject *Remove(VObject*);
virtual void RemoveFromContainer();
void SendDown(int, int, void*);
//---- acessing ----------------------------
bool Enabled()
{ return TestFlag(eVObjEnabled); }
virtual void Enable(bool b= TRUE, bool redraw= TRUE);
void Disable(bool redraw= TRUE)
{ Enable(FALSE, redraw); }
virtual bool IsOpen();
//---- sizes -------------------------------
virtual Metric GetMinSize();
int Width()
{ return contentRect.extent.x; }
int Height()
{ return contentRect.extent.y; }
int Base();
Point GetExtent()
{ return contentRect.extent; }
Point GetOrigin()
{ return contentRect.origin; };
Rectangle ContentRect()
{ return contentRect; }
void SetContentRect(Rectangle, bool);
virtual void SetExtent(Point);
virtual void ExtentChanged(VObject *what);
virtual void SetOrigin(Point);
void SetWidth(int w)
{ SetExtent(Point(w,Height())); }
void SetHeight(int h)
{ SetExtent(Point(Width(),h)); }
void Move(Point delta, bool redraw= TRUE);
void CalcExtent();
virtual void Open(bool mode= TRUE);
void Close()
{ Open(FALSE); }
void Align(Point at, Metric m, VObjAlign a);
virtual bool ContainsPoint(Point p);
//---- drawing ----------------------------
virtual void Focus();
virtual void DrawAll(Rectangle, bool highlight= FALSE);
virtual void DrawInner(Rectangle r, bool highlight= FALSE);
virtual void DrawHighlight(Rectangle);
virtual void Draw(Rectangle);
virtual void Outline2(Point, Point);
void Outline(Point delta);
// alternative interface to Outline2
void OutlineRect(Rectangle r);
// alternative interface to Outline2
virtual void Highlight(HighlightState);
virtual void InvalidateRect(Rectangle r);
virtual void InvalidateViewRect(Rectangle r);
void ForceRedraw();
void UpdateEvent();
virtual GrCursor GetCursor(Point p);
void Print();
virtual void Scroll(int mode, Point scroll, bool redraw= TRUE);
virtual void RevealRect(Rectangle, Point);
virtual void RevealAlign(Rectangle r, VObjAlign al= VObjAlign(eVObjHLeft+eVObjVTop));
void Reveal()
{ RevealRect(contentRect, contentRect.extent); }
Command *Input(Point lp, Token &t, Clipper *cl);
virtual Command *DispatchEvents(Point lp, Token &t, Clipper *cl);
virtual void DoTrackMouse(TrackPhase, Point);
virtual VObject *Detect(BoolFun f, void *arg);
// find first entry where f returns true
VObject *FindItem(int);
VObject *FindItem(Point);
VObject *FindItem(VObject*);
VObject *FindItemPtr(VObject *g);
//---- container handling ------------------
virtual void SetContainer(VObject*);
virtual void ClearContainer(VObject*);
VObject *GetContainer()
{ return container; }
VObject *FindContainerOfClass(Class *cla);
View *GetView();
Clipper *Getclipper();
Window *GetWindow();
virtual Point ContainerPoint(Point);
virtual void ReadEvent(Token &t, int timeout= -1, bool overread= TRUE);
//---- keyboard focus
bool WantsKbdFocus()
{ return TestFlag(eVObjKbdFocus); }
virtual Command *GetMover();
virtual Command *GetStretcher();
EvtHandler *GetNextHandler();
virtual Command *DoRightButtonDownCommand(Point, Token, int, Clipper*);
virtual Command *DoLeftButtonDownCommand(Point, Token, int);
virtual Command *DoMiddleButtonDownCommand(Point, Token, int);
virtual Command *DoKeyCommand(int, Token);
virtual Command *DoCursorKeyCommand(EvtCursorDir, Token);
virtual Command *DoFunctionKeyCommand(int, Token);
virtual Command *DoOtherEventCommand(Point, Token);
virtual Command *TrackInContent(Point, Token, Command*);
//---- generic methods --------------------
OStream& PrintOn(OStream&);
IStream& ReadFrom(IStream&);
void CollectParts(Collection*);
};
//---- VObjectCommand ----------------------------------------------------------
class VObjectCommand: public Command {
protected:
VObject *vop;
Rectangle oldRect, lastRect, constrainRect, newRect;
Point delta, grid;
GrCursor newcursor, oldcursor;
bool firstmove;
int hysterese;
protected:
VObjectCommand(VObject *g);
void Init(VObject *g, Rectangle cr, Point gr, GrCursor cd, int hy);
Command *TrackMouse(TrackPhase, Point, Point, Point);
void TrackConstrain(Point, Point, Point*);
void TrackFeedback(Point, Point, bool);
void DoIt();
void UndoIt();
};
//---- VObjectMover ------------------------------------------------------------
class VObjectMover: public VObjectCommand {
protected:
Point origin;
void Init(VObject *g, Rectangle cr, Point gr, GrCursor, int hy);
public:
VObjectMover(VObject*);
VObjectMover(VObject*, Rectangle);
VObjectMover(VObject*, Rectangle, Point, GrCursor cr= eCrsMoveHand, int hy= 2);
Command *TrackMouse(TrackPhase, Point, Point, Point);
};
//---- VObjectStretcher --------------------------------------------------------
class VObjectStretcher: public VObjectCommand {
protected:
Point minSize, p1, p2;
int corner;
void Init(VObject *g, Rectangle cr, Point gr, GrCursor, int hy, Point ms);
public:
VObjectStretcher(VObject*);
VObjectStretcher(VObject*, Rectangle);
VObjectStretcher(VObject*, Rectangle, Point ms);
VObjectStretcher(VObject*, Rectangle, Point ms, Point,
GrCursor cr= eCrsMoveStretch, int hy= 2);
Command *TrackMouse(TrackPhase, Point, Point, Point);
void TrackConstrain(Point, Point, Point*);
};
#endif